//修改密码
exports.change_password = function (req, res) {

    var bodyParams = req.routeInfo.bodyParams;
    //最终结果
    var resultData = {};

    var userPasswordData = 0;

    var password = common.md5(bodyParams.password);

    var new_password = common.md5(bodyParams.new_password);

    var u_id = bodyParams.u_id;

    //任务流创建
    async.waterfall([
            function (cb) {
                R.SEND_HTTP(
                    req,
                    {
                        url: CORE_APIConfig.coreAPI.search_user_info + "/u_id/" + bodyParams.u_id,
                        method: 'POST',
                        data: {
                            fields: ["u_password"].join(",")
                        }
                    },
                    function (err, data) {
                        console.log(data)
                        //判断是否有错误信息
                        if (err) {
                            return RES.response(res, false, data);
                        }
                        // resultData.userData = data;
                        userPasswordData = data.data;
                        cb();
                    }
                );
            },
            function (cb) {
                if (userPasswordData[0].u_password != password) {
                    return RES.response(res, false, "原密码输入错误");
                } else {
                    R.SEND_HTTP(
                        req,
                        {
                            url: CORE_APIConfig.coreAPI.updateUserId,
                            method: 'POST',
                            data: {
                                u_id: u_id,
                                u_password: new_password
                            }
                        },
                        function (err, data) {
                            //判断是否有错误信息
                            if (err) {
                                return RES.response(res, false, data);
                            }
                            // resultData.userData = data;
                            resultData.changeData = data;
                            cb();
                        }
                    );
                }

            },
        ], function (err, result) {
            //返回最终拼接结果
            RES.response(res, true, resultData);

        }
    );

}